Skip to content

Reject unrecognized struct tags in FromStruct#11

Merged
phinze merged 1 commit into
mainfrom
phinze/mir-985-add-unknown-struct-tag-validation-to-mflags
Apr 8, 2026
Merged

Reject unrecognized struct tags in FromStruct#11
phinze merged 1 commit into
mainfrom
phinze/mir-985-add-unknown-struct-tag-validation-to-mflags

Conversation

@phinze

@phinze phinze commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

mflags has always silently ignored struct tags it doesn't recognize. That's how positional-args:"yes" (a go-flags tag) snuck through in MIR-984 without anyone noticing, and a sweep of the runtime CLI turned up env and required tags being used on dozens of fields with no effect.

FromStruct() now validates every tag key on exported fields against the set of tags it actually reads. If anything doesn't match, it returns an error listing all the unrecognized tags at once so you can fix them in one pass. The allowlist is intentionally strict (only tags mflags implements today), so upgrading mflags in the runtime repo will surface both the go-flags holdovers and the aspirational env/required tags, prompting us to either add those features or clean up the structs.

Closes MIR-985

mflags silently ignored struct tags it didn't understand, which meant
typos and copy-paste mistakes from go-flags (like positional-args:"yes")
would compile and run fine but never actually wire anything up. A sweep
of the runtime CLI also turned up env and required tags that look
intentional but have no effect today.

FromStruct now validates every tag key on exported fields against the
set of tags it actually reads, and returns an error listing all the
unrecognized ones so you can fix them in one pass.
@phinze phinze requested a review from a team as a code owner April 8, 2026 14:58
@phinze phinze merged commit 7984ad2 into main Apr 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants